#!/bin/bash

multifile="multifile 1"
int_repeat="repeat 20"
repeat=150
timestamp=`date |sed s/\ /_/g`
repeat_tag=`echo -n $int_repeat|sed s/\ /_/g`

flagslist[0]='flushfs sync direct align random prealloc'
flagslist[1]='flushfs nosync direct align random prealloc'
flagslist[2]='flushfs nosync direct align random noprealloc'
flagslist[3]='flushfs nosync nodirect noalign random prealloc'
flagslist[4]='flushfs nosync direct align norandom prealloc'
flagslist[5]='flushfs nosync direct align norandom noprealloc'

mlabel=`echo -n "${flagslist[0]}"_"$int_repeat" |sed s/\ /_/g`
LogFile=data/tests_"$mlabel"_"$timestamp".log;
mkdir `dirname "$LogFile"`

echo>>"$LogFile"
tail -f "$LogFile" &
pid_tail=$!
echo "kill $pid_tail"
on_die()
{
    echo "Dying..."
    kill -9 $pid_tail
    exit 0
}

trap 'on_die' QUIT
trap 'on_die' INT

for f in "${flagslist[@]}";    do
    mlabel="`echo -n "$f"_"$int_repeat" |sed s/\ /_/g`"
    LogFile=data/tests_"$mlabel"_"$timestamp".log;
    echo>>"$LogFile"
    for size in `seq 1 37 18500`;
	do for rep in `seq 1 $repeat`;
        do echo -n "$size $rep "
	./io_test $((size*1024)) "$f $int_repeat" >>"$LogFile"
        done
    done
done
kill -9 $pid_tail
wait $pid_tail